package com.adcc.ags.gms.gw.vo;

import com.adcc.ags.gms.core.vo.BaseVO;
import com.adcc.ags.gms.gw.entity.SysConfiguration;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.text.ParseException;

/**
 * 告警配置视图实体
 */
public class SysConfigurationVO extends BaseVO {

    // 键
    private String key;

    // 值
    private String value;

    /**
     * 构造函数
     */
    public SysConfigurationVO() {
        super();
    }

    public SysConfigurationVO(SysConfiguration sysConfiguration) {
        if (sysConfiguration != null) {
            key = sysConfiguration.getKey();
            value = sysConfiguration.getValue();
        }
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Override
    public SysConfiguration toEntity() throws ParseException {
        SysConfiguration sysConfiguration = new SysConfiguration();
        sysConfiguration.setKey(this.key);
        sysConfiguration.setValue(this.value);
        return sysConfiguration;
    }

    @Override
    public String toJson() throws JsonProcessingException {
        return new ObjectMapper().writeValueAsString(this);
    }
}
